package com.example.nonggo.fragment;

import android.content.Intent;
import android.view.View;

import androidx.constraintlayout.widget.ConstraintLayout;

import com.example.nonggo.R;
import com.example.nonggo.base.BaseMvpFragment;
import com.example.nonggo.contract.Home2Contract;
import com.example.nonggo.presenter.Home2Presenter;
import com.example.nonggo.view.act.CallInCallActivity;
import com.example.nonggo.view.act.ExpertQaActivity;
import com.example.nonggo.view.act.MarketTrendsActivity;
import com.example.nonggo.view.act.WeatherActivity;

public class Home2Fragment extends BaseMvpFragment<Home2Contract, Home2Presenter>
        implements Home2Contract, View.OnClickListener {

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.button1) {
            Intent intent = new Intent(getActivity(), WeatherActivity.class);
            startActivity(intent);
            return;
        }
        if (v.getId() == R.id.button2) {
            Intent intent = new Intent(getContext(), ExpertQaActivity.class);
            startActivity(intent);
            return;
        }
        if (v.getId() == R.id.button3) {
            Intent intent = new Intent(getContext(), MarketTrendsActivity.class);
            startActivity(intent);
            return;
        }

        Intent intent = new Intent(getActivity(), CallInCallActivity.class);
        startActivity(intent);

    }


    @Override
    protected int getLayoutId() {
        return R.layout.fragment_home2;
    }

    @Override
    protected Home2Presenter createPresenter() {
        return new Home2Presenter();
    }

    @Override
    protected void initView(View view) {
        ConstraintLayout layout = view.findViewById(R.id.home_tabs);
        for (int index = 0; index < layout.getChildCount(); index++) {
            View childAt = layout.getChildAt(index);
            if (childAt instanceof ConstraintLayout) {
                childAt.setOnClickListener(this);
            }
        }
    }
}
